updating oE time

Routines

time

<built-in> function time() 

returns the number of seconds since some fixed point in the past.

Returns:

An atom, which represents an absolute number of seconds.

Comments:

Take the difference between two readings of time() to measure, for example, how long a section of code takes to execute.

On some machines, time() can return a negative number. However, you can still use the difference in calls to time() to measure elapsed time.

Example 1:
constant ITERATIONS = 1000000 
integer p 
atom t0, loop_overhead 
 
t0 = time() 
for i = 1 to ITERATIONS do 
    -- time an empty loop 
end for 
loop_overhead = time() - t0 
 
t0 = time() 
for i = 1 to ITERATIONS do 
    p = power(2, 20) 
end for 
? (time() - t0 - loop_overhead)/ITERATIONS 
-- calculates time (in seconds) for one call to power 
See Also:

date, now

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu